﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace School
{
    public class SchoolSystem
    {
        private List<Course> listOfCourses = new List<Course>();

        public SchoolSystem()
        {

        }

        public SchoolSystem(List<Course> courses)
        {
            this.listOfCourses = courses;
        }

        public List<Course> CourseList
        {
            get
            {
                return this.listOfCourses;
            }
            set
            {
                if (value.Count != 0)
                {
                    this.listOfCourses = value;
                }
                else
                {
                    throw new ArgumentNullException("The list of courses can not be empty!");
                }
                
            }
        }

        public void AddCourse(Course course)
        {
            this.listOfCourses.Add(course);
        }

        public void RemoveCourse(Course course)
        {
            bool courseFound = false;
            for (int i = 0; i < this.listOfCourses.Count; i++)
            {
                if (this.listOfCourses[i].NameOfCourse == course.NameOfCourse)
                {
                    courseFound = true;
                    this.listOfCourses.Remove(course);
                }
            }

            if (!courseFound)
            {
                throw new ArgumentException("The course " + course.NameOfCourse + " is not in the list of courses!");
            }
        }
    }
}
